package weaver.splittable.filter;

import org.apache.commons.lang3.StringUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class STFilter implements Filter {

    public static ThreadLocal<String> REQUEST_URL = new ThreadLocal<>();

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
        HttpServletRequest req = (HttpServletRequest) servletRequest;
        String url = req.getRequestURI();
        REQUEST_URL.set(url);
        try {
            filterChain.doFilter(servletRequest, servletResponse);
        } catch (Exception e) {

        } finally {
            REQUEST_URL.remove();
        }
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void destroy() {

    }
}
